<%@page import="java.util.ArrayList" %>
<!DOCTYPE html>
<html>
<head>
<title>Second Home Inc.</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="jquery/jquery-ui-1.11.2.custom/jquery-ui.css" />
<script type="text/javascript" src="jquery/jquery-1.11.1.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-1.11.2.custom/jquery-ui.js"></script>
<script type="text/javascript" src="validateLogin.js"></script>

</head>
<body>
  <div id="page-wrap" align="center">
  
    <!-- Navigation include -->
    <%@ include file="navigation.jsp" %>
    <!-- End Navigation include -->
    
    <br />
    <table class="main" title="Content" id="content">
    <tr><td>
    
    <p>Please log in below, or <strong><a href="register.jsp">register</a></strong>.</p>
    
    
<%
          ArrayList<String> errors = (ArrayList<String>) request
              .getAttribute( "errors" );
          if ( errors != null && errors.size() > 0 )
          {
            out.write( "<div align=\"center\">" );
            out.write( "<table><tr><td>" );

            for ( String error : errors )
            {
              out.write( "<div id=\"error\">" + error + "</div><br />" );
            }
            out.write( "</td></tr></table>" );
            out.write( "</div>" );
          }
        %>
	<table>
	  <tr>
	    <td>
	      <form name="loginForm" action="controller" onsubmit="return validateForm()" method=POST>
	      <input type="hidden" name="source" value="login" />
	      <%
	        String from = request.getParameter( "from" );
	        if ( from != null && !from.equals( "" ) )
	        {
	          out.write( "<input type=\"hidden\" name=\"from\" value=\"" + from + "\" />" );
	        }
	        
	        String checkin = request.getParameter( "check-in" );
	        if ( checkin != null && !checkin.equals( "" ) )
	        {
	          out.write( "<input type=\"hidden\" name=\"check-in\" value=\"" + checkin + "\" />" );
	        }
	        
	        String hotelName = request.getParameter( "hotelName" );
	        if ( hotelName != null && !hotelName.equals( "" ) )
	        {
	          out.write( "<input type=\"hidden\" name=\"hotelName\" value=\"" + hotelName + "\" />" );
	        }

	        String numDays = request.getParameter( "numDays" );
	        if ( numDays != null && !numDays.equals( "" ) )
	        {
	          out.write( "<input type=\"hidden\" name=\"numDays\" value=\"" + numDays + "\" />" );
	        }

	        String numPeople = request.getParameter( "numPeople" );
	        if ( numPeople != null && !numPeople.equals( "" ) )
	        {
	          out.write( "<input type=\"hidden\" name=\"numPeople\" value=\"" + numPeople + "\" />" );
	        }
	      %>
	      <input type="hidden" name="hotelName" value="login" />
          <table>
	        <tr>
	          <td style="float:right;">E-mail:<input type="TEXT" name="login_email"> <br /></td>
	        </tr>
	        <tr>
              <td style="float:right;">Password:<input type="PASSWORD" name="login_password"> <br /></td>
	        </tr>
	        <tr>
	          <td style="float: right; margin-right: 12px"><input type="SUBMIT" name="loginButton" value="Log In"></td>
	        </tr>
	      </table>
	      </form>
	  </td>
	  </tr>
	</table>

<%
  String msg = (String) request.getAttribute( "message" );
  if ( msg != null )
  {
    out.write( "<tr><td>" );
    out.write( "<div id=\"message\" align=\"center\">" );
    out.write( msg );
    out.write( "</div>" );
    out.write( "</td></tr>" );
  }
%>
    
    </td></tr></table>
    </div>
</body>
</html>